/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2024-09-12
 * Time: 11:09
 */
public abstract class Animal {
    // 抽象方法，要求子类必须实现
    public abstract void makeSound();
    // 具体方法，所有子类可以直接使用
    public void eat() {
        System.out.println("动物在吃东西");
    }
}
public class Dog extends Animal {
    @Override
    public void makeSound() {
        System.out.println("汪汪叫");
    }
}

public class Cat extends Animal {
    @Override
    public void makeSound() {
        System.out.println("喵喵叫");
    }
}

public class Main {
    public static void main(String[] args) {
        Animal dog = new Dog();
        Animal cat = new Cat();
        dog.eat(); // 输出 "动物在吃东西"
        dog.makeSound(); // 输出 "汪汪叫"
        cat.eat(); // 输出 "动物在吃东西"
        cat.makeSound(); // 输出 "喵喵叫"
    }
}